<!DOCTYPE html>
<html lang="zh-Hans">
<head>
  <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2">
<meta name="theme-color" content="#222">
<meta name="generator" content="Hexo 4.2.1">
  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png">
  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png">
  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png">
  <link rel="mask-icon" href="/images/logo.svg" color="#222">

<link rel="stylesheet" href="/css/main.css">


<link rel="stylesheet" href="/lib/font-awesome/css/all.min.css">
  <link rel="stylesheet" href="/lib/pace/pace-theme-minimal.min.css">
  <script src="/lib/pace/pace.min.js"></script>

<script id="hexo-configurations">
    var NexT = window.NexT || {};
    var CONFIG = {"hostname":"sophimp.gitee.io","root":"/","scheme":"Pisces","version":"7.8.0","exturl":false,"sidebar":{"position":"left","display":"post","padding":18,"offset":12,"onmobile":false},"copycode":{"enable":false,"show_result":false,"style":null},"back2top":{"enable":true,"sidebar":false,"scrollpercent":true},"bookmark":{"enable":false,"color":"#222","save":"auto"},"fancybox":false,"mediumzoom":false,"lazyload":false,"pangu":false,"comments":{"style":"tabs","active":null,"storage":true,"lazyload":false,"nav":null},"algolia":{"hits":{"per_page":10},"labels":{"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}},"localsearch":{"enable":false,"trigger":"auto","top_n_per_article":1,"unescape":false,"preload":false},"motion":{"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}}};
  </script>

  <meta name="description" content="hexo + github + gitpage 搭建个人博客， 想法的记录， 思考过程的展现， 以及配置的展示。">
<meta property="og:type" content="article">
<meta property="og:title" content="Hexo + github + gitpage 搭建blog">
<meta property="og:url" content="http://sophimp.gitee.io/2020/07/18/others/build-blog-with-hexo/index.html">
<meta property="og:site_name" content="Sophimp&#39;s Space">
<meta property="og:description" content="hexo + github + gitpage 搭建个人博客， 想法的记录， 思考过程的展现， 以及配置的展示。">
<meta property="article:published_time" content="2020-07-18T15:47:43.000Z">
<meta property="article:modified_time" content="2021-08-12T07:02:44.501Z">
<meta property="article:author" content="Sophimp">
<meta property="article:tag" content="博客搭建">
<meta name="twitter:card" content="summary">

<link rel="canonical" href="http://sophimp.gitee.io/2020/07/18/others/build-blog-with-hexo/">


<script id="page-configurations">
  // https://hexo.io/docs/variables.html
  CONFIG.page = {
    sidebar: "",
    isHome : false,
    isPost : true,
    lang   : 'zh-Hans'
  };
</script>

  <title>Hexo + github + gitpage 搭建blog | Sophimp's Space</title>
  






  <noscript>
  <style>
  .use-motion .brand,
  .use-motion .menu-item,
  .sidebar-inner,
  .use-motion .post-block,
  .use-motion .pagination,
  .use-motion .comments,
  .use-motion .post-header,
  .use-motion .post-body,
  .use-motion .collection-header { opacity: initial; }

  .use-motion .site-title,
  .use-motion .site-subtitle {
    opacity: initial;
    top: initial;
  }

  .use-motion .logo-line-before i { left: initial; }
  .use-motion .logo-line-after i { right: initial; }
  </style>
</noscript>

</head>

<body itemscope itemtype="http://schema.org/WebPage">
  <div class="container use-motion">
    <div class="headband"></div>

	
	<script type="text/javascript" src="//cdn.bootcss.com/canvas-nest.js/1.0.0/canvas-nest.min.js"></script>
	

    <header class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-container">
  <div class="site-nav-toggle">
    <div class="toggle" aria-label="Toggle navigation bar">
      <span class="toggle-line toggle-line-first"></span>
      <span class="toggle-line toggle-line-middle"></span>
      <span class="toggle-line toggle-line-last"></span>
    </div>
  </div>

  <div class="site-meta">

    <a href="/" class="brand" rel="start">
      <span class="logo-line-before"><i></i></span>
      <h1 class="site-title">Sophimp's Space</h1>
      <span class="logo-line-after"><i></i></span>
    </a>
      <p class="site-subtitle" itemprop="description">coding & thinking</p>
  </div>

  <div class="site-nav-right">
    <div class="toggle popup-trigger">
    </div>
  </div>
</div>




<nav class="site-nav">
  <ul id="menu" class="main-menu menu">
        <li class="menu-item menu-item-home">

    <a href="/" rel="section"><i class="fa fa-home fa-fw"></i>Home</a>

  </li>
        <li class="menu-item menu-item-archives">

    <a href="/archives/" rel="section"><i class="fa fa-archive fa-fw"></i>Archives</a>

  </li>
  </ul>
</nav>




</div>
    </header>

    
  <div class="back-to-top">
    <i class="fa fa-arrow-up"></i>
    <span>0%</span>
  </div>
  <div class="reading-progress-bar"></div>

  <a href="https://github.com/sophimp" class="github-corner" title="Follow me on GitHub" aria-label="Follow me on GitHub" rel="noopener" target="_blank"><svg width="80" height="80" viewBox="0 0 250 250" aria-hidden="true"><path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"></path><path d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2" fill="currentColor" style="transform-origin: 130px 106px;" class="octo-arm"></path><path d="M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z" fill="currentColor" class="octo-body"></path></svg></a>


    <main class="main">
      <div class="main-inner">
        <div class="content-wrap">
          

          <div class="content post posts-expand">
            

    
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-Hans">
    <link itemprop="mainEntityOfPage" href="http://sophimp.gitee.io/2020/07/18/others/build-blog-with-hexo/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.png">
      <meta itemprop="name" content="Sophimp">
      <meta itemprop="description" content="A dream begin">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="Sophimp's Space">
    </span>
      <header class="post-header">
        <h1 class="post-title" itemprop="name headline">
          Hexo + github + gitpage 搭建blog
        </h1>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-calendar"></i>
              </span>
              <span class="post-meta-item-text">Posted on</span>

              <time title="Created: 2020-07-18 23:47:43" itemprop="dateCreated datePublished" datetime="2020-07-18T23:47:43+08:00">2020-07-18</time>
            </span>
              <span class="post-meta-item">
                <span class="post-meta-item-icon">
                  <i class="far fa-calendar-check"></i>
                </span>
                <span class="post-meta-item-text">Edited on</span>
                <time title="Modified: 2021-08-12 15:02:44" itemprop="dateModified" datetime="2021-08-12T15:02:44+08:00">2021-08-12</time>
              </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-folder"></i>
              </span>
              <span class="post-meta-item-text">In</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/hexo/" itemprop="url" rel="index"><span itemprop="name">hexo</span></a>
                </span>
            </span>

          
            <span class="post-meta-item" title="Views" id="busuanzi_container_page_pv" style="display: none;">
              <span class="post-meta-item-icon">
                <i class="fa fa-eye"></i>
              </span>
              <span class="post-meta-item-text">Views: </span>
              <span id="busuanzi_value_page_pv"></span>
            </span>
            <div class="post-description">hexo + github + gitpage 搭建个人博客， 想法的记录， 思考过程的展现， 以及配置的展示。</div>

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
        <h2 id="使用-Hexo-github-gitpage-搭建博客"><a href="#使用-Hexo-github-gitpage-搭建博客" class="headerlink" title="使用 Hexo + github + gitpage 搭建博客"></a>使用 Hexo + github + gitpage 搭建博客</h2><p>搭建博客，相比如内容，所需的搭建技术反而是次要的。</p>
<p>博客放哪些内容， 采用什么样的布局，什么样的风格, 这些做到胸中了然， 搭建的过程，哪里不会搜哪里即可。<br>以我的经验来看， 想要搭一个什么样的博客， 绝大多数人一开始是做不到心中有数的。 这也是很多人大多数时候无从下手的根本原因。所谓万事开头难, 不过如此。</p>
<p>那么如何解决万事开头难的问题呢？<br>迭代思想! </p>
<h3 id="基本需求"><a href="#基本需求" class="headerlink" title="基本需求"></a>基本需求</h3><p>迭代的核心思想：开始不要想得太细致完美，满足基本需求，发布初始版本，然后逐版本迭代。 </p>
<blockquote>
<p>先分析最根本的需求：记录思想，复盘，分享。</p>
</blockquote>
<p>满足这些需求， 我只需写出blog，然后部署到公网被访问即可。</p>
<p>写blog, 有最基本的编辑器就可以完成。 部署到公网需要服务器，域名。</p>
<p>那么开始搜索<code>搭建博客</code>, 在结果里统计一些方案, 满足以上需求， 就可以按教程开始搭建博客了。</p>
<p>这里我选择 hexo + github + gitpage 搭建博客, 主要有以下考量:</p>
<ul>
<li>hexo 是当前最流行的博客管理框架，流行意味着学习资料多, 这里切莫为了彰显个性而刻意不同, 记住建博客的初衷, 花样上的个性并没有想象中的酷，内容上的深度才是彰显个性的根本。</li>
<li>github 可以满足云同步， 且迭代版本跟踪。是个神器， 一个合格的程序员都知道, 不是程序员学一学也绝对是百利无一害。</li>
<li>gitpage 可以解决服务器与域名的问题，虽然只有目前有1G的容量的限制， 但是写博客是绝对够用了, 当然， 有视频与图片， 最好放在专门的服务器使用网络链接。</li>
</ul>
<p>至于hexo安装, github 使用， gitpage 开启，参考官方文档，结合其他博主写的教程，可以快速上手, 这里就不详细写了。</p>
<p><a href="https://hexo.bootcss.com/docs/" target="_blank" rel="noopener">hexo 官方文档</a><br><a href="https://github.com/hexojs/hexo" target="_blank" rel="noopener">hexo github 项目</a><br><a href="https://git-scm.com/book/zh/v2" target="_blank" rel="noopener">git使用手册</a><br><a href="https://pages.github.com/" target="_blank" rel="noopener">gitpage 文档</a></p>
<blockquote>
<p><strong>提示</strong><br>使用hexo, 搭建一个博客的思想很简单，hexo 就当作普通软件安装使用，学一下markdown语法，主题先使用默认的，接下来着重开始写文章，使用一段时间后， 对hexo比较熟悉了再尝试去美化博客， 添加其他的功能。 我们的主要目的是为了内容输出，博客搭建技术是手段。当然， 本职工作本就是前端开发的话, 搭建博客的技术就成了主要目标。</p>
</blockquote>
<h3 id="定制化需求"><a href="#定制化需求" class="headerlink" title="定制化需求"></a>定制化需求</h3><p>完成基本的需求, 随着写博客的过程，逐步迭代满足定制化需求。</p>
<p>定制化也要先解决想要什么的问题。如何布局博客, 我是先参考 <a href="http://blankj.github.io/" target="_blank" rel="noopener">Blankj’s Blog</a> 的风格。 使用的是 <a href="https://github.com/theme-next/hexo-theme-next" target="_blank" rel="noopener">next</a> 主题。</p>
<p>Next 主题目前基本上满足了我的需求： </p>
<p>侧边栏, 首页，归档， 标签，分类，分页。这些功能已经满足了文章的管理需求。 后续再添加上评论。</p>
<p>关于next主题的配置，网络上已经有了很多<a href="https://blog.csdn.net/u012294515/article/details/83094693" target="_blank" rel="noopener">教程</a>，不过大部分都与当前最新版本有些差别, 这里需要灵活对待。 </p>
<p><code>hexo init</code> 的根目录下的 <code>_config.yml</code> 是全局配置，themes/next 下的 <code>_config.yml</code> 是针对主题的配置。仔细看这两个文件的注释，大部分是打开开关的操作，对比着教程中的关键词， 搜索着配置即可。 </p>
<p>这里有几点建议: </p>
<ol>
<li>不要搞得太花哩胡哨的， 因为github 的在国内的访问速度毕竟还是慢一些。</li>
<li>整体的界面保持简洁， 保持影响阅读体验的良好。所以，够用，方便阅读, 查找，更新，管理文章即可。</li>
</ol>
<p><a href="https://gitee.com/sophimp/hexo-theme-next" target="_blank" rel="noopener">个人的next定制仓库</a></p>
<h3 id="博客管理"><a href="#博客管理" class="headerlink" title="博客管理"></a>博客管理</h3><p>官方推荐的是博客原文与部署文件分两个仓库管理。 </p>
<figure class="highlight sh"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">hexo new page  &lt;page name&gt; <span class="comment"># 是在图像下添加标签页的 如 post, categories, tags</span></span><br><span class="line">hexo new &lt;file name&gt; <span class="comment"># 默认是在 source/_post 文件夹下创建一个md 文件， 使用的是 scaffolds/_post.md 作为模板 </span></span><br><span class="line"></span><br><span class="line"><span class="comment"># 如果想要博客原文也分文件夹管理，直接在 source/_post 下创建文件夹，然后通过复制 _post.md 到指定的文件夹下来创建博客. 是可以达到原文博客的分类管理。</span></span><br></pre></td></tr></table></figure>

<p>使用 categories, tags, 时间轴，基本上就可以快速定位到blog, 满足管理需求。 当然再加上一个<code>搜索</code>功能更好。</p>
<h3 id="技巧点"><a href="#技巧点" class="headerlink" title="技巧点"></a>技巧点</h3><p>文章相对路径引用(<code>&lt;&gt; 代表必填项 [] 代表选填项</code>, 这是命令文档中的约定 )<br>文章的相对路径是相对于_post文件夹的</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">&#123;% post_link &lt;文章的相对路径&gt; [文章的章节名称] %&#125;&#96;</span><br></pre></td></tr></table></figure>

<p>显示相对路径</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">&#123;% post_path &lt;文章的相对路径&gt; %&#125;</span><br></pre></td></tr></table></figure>

<p>文章资源引用</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">&#123;% asset_path &lt;资源相对路径&gt; %&#125;</span><br><span class="line">&#123;% asset_img &lt;图片相对路径&gt; [图片名称]%&#125;</span><br><span class="line">&#123;% asset_link &lt;资源相对路径&gt; [资源的子标题]%&#125;</span><br></pre></td></tr></table></figure>

<p><a href="https://blog.csdn.net/TomAndersen/article/details/104872852" target="_blank" rel="noopener">设置背景图</a></p>
<h3 id="持续迭代"><a href="#持续迭代" class="headerlink" title="持续迭代"></a>持续迭代</h3><p>后面有想法， 再更新。</p>

    </div>

    
    
    

      <footer class="post-footer">
          <div class="post-tags">
              <a href="/tags/%E5%8D%9A%E5%AE%A2%E6%90%AD%E5%BB%BA/" rel="tag"># 博客搭建</a>
          </div>

        


        
    <div class="post-nav">
      <div class="post-nav-item">
    <a href="/2020/07/16/thought/about-blog/" rel="prev" title="关于博客">
      <i class="fa fa-chevron-left"></i> 关于博客
    </a></div>
      <div class="post-nav-item">
    <a href="/2020/07/21/linux/archlinux-kde-FAQ-md/" rel="next" title="archlinux-kde 使用日常记录(持续更新)">
      archlinux-kde 使用日常记录(持续更新) <i class="fa fa-chevron-right"></i>
    </a></div>
    </div>
      </footer>
    
  </article>
  
  
  



          </div>
          

<script>
  window.addEventListener('tabs:register', () => {
    let { activeClass } = CONFIG.comments;
    if (CONFIG.comments.storage) {
      activeClass = localStorage.getItem('comments_active') || activeClass;
    }
    if (activeClass) {
      let activeTab = document.querySelector(`a[href="#comment-${activeClass}"]`);
      if (activeTab) {
        activeTab.click();
      }
    }
  });
  if (CONFIG.comments.storage) {
    window.addEventListener('tabs:click', event => {
      if (!event.target.matches('.tabs-comment .tab-content .tab-pane')) return;
      let commentClass = event.target.classList[1];
      localStorage.setItem('comments_active', commentClass);
    });
  }
</script>

        </div>
          
  
  <div class="toggle sidebar-toggle">
    <span class="toggle-line toggle-line-first"></span>
    <span class="toggle-line toggle-line-middle"></span>
    <span class="toggle-line toggle-line-last"></span>
  </div>

  <aside class="sidebar">
    <div class="sidebar-inner">

      <ul class="sidebar-nav motion-element">
        <li class="sidebar-nav-toc">
          Table of Contents
        </li>
        <li class="sidebar-nav-overview">
          Overview
        </li>
      </ul>

      <!--noindex-->
      <div class="post-toc-wrap sidebar-panel">
          <div class="post-toc motion-element"><ol class="nav"><li class="nav-item nav-level-2"><a class="nav-link" href="#使用-Hexo-github-gitpage-搭建博客"><span class="nav-number">1.</span> <span class="nav-text">使用 Hexo + github + gitpage 搭建博客</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#基本需求"><span class="nav-number">1.1.</span> <span class="nav-text">基本需求</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#定制化需求"><span class="nav-number">1.2.</span> <span class="nav-text">定制化需求</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#博客管理"><span class="nav-number">1.3.</span> <span class="nav-text">博客管理</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#技巧点"><span class="nav-number">1.4.</span> <span class="nav-text">技巧点</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#持续迭代"><span class="nav-number">1.5.</span> <span class="nav-text">持续迭代</span></a></li></ol></li></ol></div>
      </div>
      <!--/noindex-->

      <div class="site-overview-wrap sidebar-panel">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
    <img class="site-author-image" itemprop="image" alt="Sophimp"
      src="/images/avatar.png">
  <p class="site-author-name" itemprop="name">Sophimp</p>
  <div class="site-description" itemprop="description">A dream begin</div>
</div>
<div class="site-state-wrap motion-element">
  <nav class="site-state">
      <div class="site-state-item site-state-posts">
          <a href="/archives/">
        
          <span class="site-state-item-count">86</span>
          <span class="site-state-item-name">posts</span>
        </a>
      </div>
      <div class="site-state-item site-state-categories">
            <a href="/categories/">
        <span class="site-state-item-count">19</span>
        <span class="site-state-item-name">categories</span></a>
      </div>
      <div class="site-state-item site-state-tags">
            <a href="/tags/">
        <span class="site-state-item-count">89</span>
        <span class="site-state-item-name">tags</span></a>
      </div>
  </nav>
</div>
  <div class="links-of-author motion-element">
      <span class="links-of-author-item">
        <a href="https://github.com/sophimp" title="GitHub → https:&#x2F;&#x2F;github.com&#x2F;sophimp" rel="noopener" target="_blank"><i class="fab fa-github fa-fw"></i>GitHub</a>
      </span>
      <span class="links-of-author-item">
        <a href="mailto:sophimp2020@126.com" title="E-Mail → mailto:sophimp2020@126.com" rel="noopener" target="_blank"><i class="fa fa-envelope fa-fw"></i>E-Mail</a>
      </span>
  </div>



      </div>

    </div>
  </aside>
  <div id="sidebar-dimmer"></div>


      </div>
    </main>

    <footer class="footer">
      <div class="footer-inner">
        

        

<div class="copyright">
  
  &copy; 
  <span itemprop="copyrightYear">2021</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">Sophimp</span>
</div>

<!--
  <div class="powered-by">Powered by <a href="https://hexo.io/" class="theme-link" rel="noopener" target="_blank">Hexo</a> & <a href="https://pisces.theme-next.org/" class="theme-link" rel="noopener" target="_blank">NexT.Pisces</a>
  </div>
-->

        
<div class="busuanzi-count">
  <script async src="https://busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>
    <span class="post-meta-item" id="busuanzi_container_site_uv" style="display: none;">
      <span class="post-meta-item-icon">
        <i class="fa fa-user"></i>
      </span>
      <span class="site-uv" title="Total Visitors">
        <span id="busuanzi_value_site_uv"></span>
      </span>
    </span>
    <span class="post-meta-divider">|</span>
    <span class="post-meta-item" id="busuanzi_container_site_pv" style="display: none;">
      <span class="post-meta-item-icon">
        <i class="fa fa-eye"></i>
      </span>
      <span class="site-pv" title="Total Views">
        <span id="busuanzi_value_site_pv"></span>
      </span>
    </span>
</div>








      </div>
    </footer>
  </div>

  
  <script src="/lib/anime.min.js"></script>
  <script src="/lib/velocity/velocity.min.js"></script>
  <script src="/lib/velocity/velocity.ui.min.js"></script>

<script src="/js/utils.js"></script>

<script src="/js/motion.js"></script>


<script src="/js/schemes/pisces.js"></script>


<script src="/js/next-boot.js"></script>




  















  

  

</body>
</html>
